package com.hpeu_01.day0125.hemowork;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 第一题：客户端给服务端发送文本，服务端会将文本转成大写在返回给客户
 */
//客服端
public class Client {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 6666);
            OutputStream os = socket.getOutputStream();
            os.write("hpeu".getBytes());

            InputStream is = socket.getInputStream();
            byte[] b = new byte[1024];
            int len = is.read(b);
            System.out.println(new String(b, 0, len));

            is.close();
            os.close();
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
